/**
 *
 */
package com.wedroid.api.service.impl;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.demo2do.core.persistence.GenericDaoSupport;
import com.wedroid.api.service.AdminService;
import com.wedroid.entity.contact.ContacterType;

/**
 * @author lute
 */
@Service("adminService")
public class AdminServiceImpl implements AdminService {

    @Autowired
    private GenericDaoSupport genericDaoSupport;

    /* (non-Javadoc)
     * @see com.wedroid.api.service.AdminService#countGroups()
     */
    public int countGroups() {
        String sentence = "COUNT (*) FROM Contacter contacter WHERE contacter.contacterType = :type";

        Map<String, Object> parameters = new HashMap<>();
        parameters.put("type", ContacterType.GROUP.name());

        return genericDaoSupport.count(sentence, parameters);
    }

    /* (non-Javadoc)
     * @see com.wedroid.api.service.AdminService#countGroupMembers()
     */
    public int countGroupMembers() {
        return genericDaoSupport.count("COUNT (*) FROM GroupMember", Collections.emptyMap());
    }

    /* (non-Javadoc)
     * @see com.wedroid.api.service.AdminService#countMessages()
     */
    public int countMessages() {
        return genericDaoSupport.count("COUNT (*) FROM Message", Collections.emptyMap());
    }

    /* (non-Javadoc)
     * @see com.wedroid.api.service.AdminService#countCommands()
     */
    public int countCommands() {
        return genericDaoSupport.count("COUNT (*) FROM Command", Collections.emptyMap());
    }

}
